<div class="your-city-popup">
	<h3 class="popup-title">Выберите ваш город</h3>
	<ul class="your-city-popup__list">
		<?php
		foreach( Yii::app()->params[ 'regions' ] as $region )
		{
			$class = '';
			if ( $region['regionId'] == Yii::app()->session['userRegion']['id'])
			{
				$class = ' class="selected" ';
			}
			echo '<li '.$class.'><a href="#"><span data-id="' . $region[ 'regionId' ] . '">' . $region[ 'regionTitle' ] . '</span></a></li>';
		}
		$defaultRegion = mTools::getDefaultRegion();

		echo '<li><a href="#"><span data-id="'.$defaultRegion['regionId'].'">Другой город</span></a></li>';
		?>
	</ul>	
</div>
<script>
	$(function()
	{
		$('div.your-city-popup').on("click", "a>span", function()
		{
			var pli = $(this).parents('li');
			if (pli.hasClass("selected"))
			{
				$(this).parents('div.fancybox-skin').find('.fancybox-close').trigger("click");
				return false;
			}
			var regionId = $(this).data("id");
			var regionTitle = $(this).html();
			$('span.header__top-panel__left__address>a').html($(this).html());
			$('span#footer_region_title').html(regionTitle);
			$.ajax({
				url: '/main/ajax/setRegion',
				type:'post',
				data: {regionId: regionId},
				success: function( data ) 
				{
					data = JSON.parse( data );
					mobi03.setUData({'userRegion': {'title': regionTitle, 'id': regionId}});
					if ( regionId == 1 && data.firstTime == 'yes')
					{
						
					} else
					{
						location.reload();
					}
				}
			});
			$('div.your-city-popup').parents('div.fancybox-opened').find('.fancybox-close').trigger("click");
			return false;
		});
	});
</script> 
